package com.kdg;

/**
 * Created by Administrator on 2017/8/22.
 * java8新增default关键字，为接口声明添加非抽象的方法实现  此特性称为扩展方法
 */
public interface TestDefault {
    double add(int a);
    default double sqrt(double a){
        return Math.sqrt(a);
    }
}

class DefaultTest{
    public static void main(String[] args) {
        TestDefault dft = new TestDefault() {
            @Override
            public double add(int a) {
                return sqrt(9);
            }
        };
        double res1 = dft.add(10);
        double res2 = dft.sqrt(16);
        System.out.println(res1+"---"+res2);

    }
}
